<template>
  <el-select-v2 v-model="mealCenterId" placeholder="请选择出餐中心" :options="options" :props="props" value-key="id"/>
</template>
<script lang="ts" setup>
import {ref} from "vue"
import {ElSelectV2} from "element-plus";
import {getMealCenters} from "@/api/mealCenter";
import {MealCenterResponse} from "@/api/types/mealCenter";

const mealCenterId = defineModel<number>()

const options = ref<MealCenterResponse[]>([])
const props = {
  label: "name",
  value: "id"
}

async function getData() {
  const {result} = await getMealCenters()
  if (result !== undefined) {
    options.value = result
  }
}

getData()
</script>
